<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            display: flex;
        }
        
        .box>div {
            width: 100px;
            height: 100px;
            background: #000;
            margin-left: 10px;
        }
    </style>
</head>

<body>
    <button onclick="add()">点击变红色</button>
    <div class="box">

        <div></div>
        <div></div>
        <div></div>
    </div>
</body>
<script>
    let box = document.querySelectorAll('.box>div')
    console.log(box);

    function add() {
        box[0].style.backgroundColor = box[1].style.backgroundColor = box[2].style.backgroundColor = "red"
    }
</script>

</html>